﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HMI.Tool
{
    public class SqlHelper
    {

        public static SQLiteConnection conn = null;
        internal DataSet dbset = null;
        internal SQLiteDataAdapter adapter = null;
        public void CreateDB(string name)
        {

        }
        public static void OpenDb()
        {
            conn = new SQLiteConnection();
            conn.ConnectionString = "Data Source=data.db;Version=3";
        }
        public void RunSql(string sql)
        {
            dbset = new DataSet();
            adapter = new SQLiteDataAdapter(sql, conn);
            adapter.Fill(dbset);
            Console.WriteLine(sql);
        }
        public DataTable GetTables(string sql)
        {
            RunSql(sql);
            return dbset.Tables[0];
        }
    }
}
